/**
* All Rights Reserved , Copyright (C) 2023 , 青岛鼎信通讯股份有限公司
*
* MeetManageHistoryService
* 会议管理历史
*
* 修改纪录
* 2023-03-30 版本：1.0 wangxinhua 创建。
* @version 版本：1.0
* @author 作者：wangxinhua
* 创建日期：2023-03-30
*/
package com.topscomm.meet.service.impl;

import com.topscomm.meet.pojo.MeetTypeManageEntity;
import com.topscomm.meet.service.IMeetTypeManageService;
import com.topscomm.tap.common.DatacodeCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.meet.service.IMeetManageHistoryService;
import com.topscomm.meet.service.impl.auto.MeetManageHistoryServiceAuto;

import java.util.List;
import java.util.Map;

@Service(value = "meetManageHistoryService")
@Scope(value = "singleton")
public class MeetManageHistoryService extends MeetManageHistoryServiceAuto implements IMeetManageHistoryService {
    @Autowired
    private IMeetTypeManageService meetTypeManageService;
    /**
     * @param mapRow
     * @param datacodeCache
     * @description:
     * @author: donghang
     * @date: 2020年11月9日上午9:12:16
     * @modify:
     */
    @Override
    public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
        super.setDispFields(mapRow, datacodeCache);
        String temp;
        //todo 优化此处代码 使用Redis缓存查询join的方法进行
        if (mapRow.get("meettypeid") != null) {
            temp = mapRow.get("meettypeid").toString();
            String name = "", parentName = "";
            List<MeetTypeManageEntity> meetList = this.meetTypeManageService.queryByWhere("id=" + temp);
            if (meetList.size() == 1) {
                name = meetList.get(0).getName();
                if (meetList.get(0).getParentid() > 0) {
                    List<MeetTypeManageEntity> parentList = this.meetTypeManageService
                            .queryByWhere("id=" + meetList.get(0).getParentid());
                    if (parentList.size() == 1) {
                        parentName = parentList.get(0).getName();
                    }
                }
            }
            if (parentName.length() > 0) {
                mapRow.put("dispmeettypeid", parentName + "/" + name);
            } else {
                mapRow.put("dispmeettypeid", name);
            }

        }
    }

}
